home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 September / Macworld (1998-09).dmg / Shareware World / Info / For Developers / MacZoop 1.8.3 / More Classes / Plug-In Classes / ZPlugInHandler.h < prev   
Text File  |  1997-12-18  |  2KB  |  74 lines

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            MacZoop - "the framework for the rest of us"         
  5. *
  6. *
  7. *
  8. *            ZPlugInHandler.h    -- an object for managing plug-ins
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1997, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21. #pragma once
  22.  
  23. #ifndef __ZPLUGINHANDLER__
  24. #define    __ZPLUGINHANDLER__
  25.  
  26.  
  27. #include    "ZFolderScanner.h"
  28. #include    "ZPlugIn.h"
  29. #include    "ZObjectArray.h"
  30.  
  31.  
  32.  
  33. typedef ZObjectArray<ZPlugIn>    ZPlugInList;
  34.  
  35.  
  36.  
  37. class    ZPlugInHandler    : public ZFolderScanner
  38. {
  39. protected:
  40.     ZPlugInList*    itsPlugIns;
  41.     
  42. public:
  43.  
  44.     ZPlugInHandler( const FSSpec& rootFolder );
  45.     ~ZPlugInHandler();
  46.     
  47.     virtual void        InitPlugIns();
  48.     virtual void        SendMessageToPlugIn( const short plugID, const long message, void* msgData );
  49.     virtual void        SendMessageToAll( const long message, void* msgData );
  50.     virtual void        BuildMenuOfPlugIns( MenuHandle aMenu );
  51.     virtual short        CountPlugIns() { return itsPlugIns->CountItems(); };
  52.     
  53. protected:
  54.     virtual void        Process1File( const FSSpec& aSpec, const OSType fType );
  55.     virtual ZPlugIn*    MakePlugIn( const FSSpec& aSpec, const OSType fType );
  56. };
  57.  
  58.  
  59. // this object is part of a generalised plug-in architecture. It is based on ZFolderScanner
  60. // and what is expected is that valid plug-ins will reside in some folder or a hierarchy of
  61. // folders. As each plug-in file is passed to Process1File, this will create a plug-in object
  62. // and keep it in its list of plug-ins. You need to override MakePlugIn to make the correct
  63. // type of ZPlugIn object (since ZPlugIn itself is an abstract class that does nothing).
  64.  
  65. // normally you'll make one of these as a global object as part of building your application.
  66. // You then need to call InitPlugIns at some point to kick off the scan for plug-ins.
  67.  
  68. // The responsibility for establishing a user-interface to access the plug-ins is entirely
  69. // yours- this provides a single simple method for building a menu of plug-ins but handling
  70. // this menu is your responsibility. It is not recommended that a menu of plug-ins is the
  71. // best way to implement a user-interface, though it may be appropriate for simple uses.
  72.  
  73.  
  74. #endif